import 'package:flutter/material.dart';
import 'button_demo.dart';
import 'form_demo.dart';
import 'checkbox_demo.dart';
import 'Radio_demo.dart';
import 'Switch_demo.dart';
import 'slider_demo.dart';
import 'datetime_demo.dart';
import 'simple_dialog_demo.dart';
import 'alert_dialog_demo.dart';
import 'bottom_sheet_demo.dart';
import 'snack_bar_demo.dart';
import 'expansion_panel_demo.dart';

class MaterialComponent extends StatelessWidget {
  const MaterialComponent({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(     
      appBar: AppBar(
        title: Text('Component')
      ),
      body: ListView(
        children: <Widget>[
          ListItem(title:'floatActionButtonDemo',page:FloatButtonDemo()),
          ListItem(title:'ButtonDemo',page:ButtonDemo()),
          ListItem(title:'popupMenuButtonDemo',page:PopupMenuButtonDemo()),
          ListItem(title:'FormDemo',page:FormDemo()),
          ListItem(title:'checkBoxDemo',page:CheckBoxDemo()),
          ListItem(title:'radioDemo',page:RadioDemo()),
          ListItem(title:'switchDemo',page:SwitchDemo()),
          ListItem(title:'sliderDemo',page:SliderDemo()),
          ListItem(title:'dateTimeDemo',page:DatetimeDemo()),
          ListItem(title:'SimpleDialogDemo',page:SimpleDialogDemo()),
          ListItem(title:'alertDialogDemo',page:AlertDialogDemo()),
          ListItem(title:'bottomSheetDemo',page:BottomSheetDemo()),
          ListItem(title:'snackBarDemo',page:SnackBarDemo()),
          ListItem(title:'ExpansionPanelDemo',page:ExpansionPanelDemo()),
        ]
      ),
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;
  final Widget page;
  
  const ListItem({Key key, this.title, this.page}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListTile(
        title: Text(title),
        onTap: (){
          Navigator.of(context).push(
            MaterialPageRoute(builder: (context) => page)
          );
        },
      ),
    );
  }
}